home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 2 / LSD and 17bit Compendium Deluxe - Volume II.iso / a / prog / asmsrc / starcreate.lha / stars1
Encoding:
Text File  |  1989-06-22  |  6.0 KB  |  330 lines

  1.     section andy,code_c
  2.     opt c-
  3.  
  4.     *************************
  5.     * Setup V2.1 Rev.3/3/90 *
  6.     *************************
  7.  
  8. startlist1    equ    38
  9. startlist2    equ    50
  10.  
  11. plnw        equ    40
  12. plnh        equ    256
  13. plnsize        equ    plnw*plnh
  14. plnnum        equ    1
  15. plndata        equ    plnsize*plnnum
  16.  
  17.     move.l    4,a6
  18.     move.l    #$10002,d1
  19.     move.l    #plndata,d0
  20.     jsr    -198(a6)
  21.     cmp.l    #$00,d0
  22.     beq    error
  23.     move.l    d0,plnbase
  24.  
  25.     move.l    4,a6
  26.     move.l    #gfxname,a1
  27.     moveq.l    #0,d0
  28.     jsr    -552(a6)
  29.     move.l    d0,gfxbase
  30.  
  31.     MOVE.W    #$0080,$dff096
  32.     move.w    $dff01c,sysint
  33.     or.w    #$c000,sysint
  34.     move.w    #$7fff,$dff09a
  35.     move.w    #$c020,$dff09a
  36.     move.l    $6c,intsave
  37.     move.l    #newcopper,$dff080
  38.     clr.w    $dff088
  39.     move.w    #$8480,$dff096    
  40.     move.l    plnbase,a1
  41.     move.l    #plnsize,d0
  42.     move.l    a1,stor
  43.     move.l    stor,pln1
  44.     move.w    stor,bp1+2
  45.     move.w    stor+2,bp1+6
  46.  
  47.     jsr    killspr
  48.     jsr    stars_on
  49.  
  50.     move.w    #0,$dff180
  51.     move.l    #isr,$6c
  52.  
  53. wait:    jsr    task            ;jmp to our sub.
  54.     btst    #6,$bfe001        ;wait for mouse.
  55.     bne    wait
  56.     move.l    gfxbase,a4
  57.     move.l    startlist1(a4),$dff080
  58.     move.l    startlist2(a4),$dff084
  59.     clr.w    $dff088    
  60.     move.l    intsave,$6c
  61.     move.w    sysint,$dff09a
  62.     move.w    #$8080,$dff096
  63.     move.w    #$0400,$dff096
  64.     move.l    4,a6
  65.     move.l    plnbase,a1
  66.     move.l    #plndata,d0
  67.     jsr    -210(a6)
  68.     move.l    gfxbase,a1
  69.     jsr    -414(a6)
  70.  
  71. error:    move.w    #$0fff,$dff180
  72.     rts                ;exit.
  73.  
  74. newcopper:                    
  75.     dc.w    $0100,$1200
  76. scrl:    dc.w    $0102,$0000
  77.  
  78. bp1:    dc.w    $00e0,$0000,$00e2,$0000
  79. bp2:    dc.w    $00e4,$0000,$00e6,$0000
  80. bp3:    dc.w    $00e8,$0000,$00ea,$0000
  81. bp4:    dc.w    $00ec,$0000,$00ee,$0000
  82. bp5:    dc.w    $00f0,$0000,$00f2,$0000
  83.  
  84.     dc.w    $008E,$2c81,$0090,$2cc1                                 
  85.     dc.w    $0092,$0038,$0094,$00d0
  86. mod:    dc.w    $0108,$0000,$010a,$0000
  87.  
  88. sp0:    dc.w    $0120,$0000,$0122,$0000    
  89. sp1:    dc.w    $0124,$0000,$0126,$0000    
  90. sp2:    dc.w    $0128,$0000,$012a,$0000    
  91. sp3:    dc.w    $012c,$0000,$012e,$0000    
  92. sp4:    dc.w    $0130,$0000,$0132,$0000    
  93. sp5:    dc.w    $0134,$0000,$0136,$0000    
  94. sp6:    dc.w    $0138,$0000,$013a,$0000    
  95. sp7:    dc.w    $013c,$0000,$013e,$0000    
  96.  
  97.     dc.w    $01a2,$0fff
  98.     dc.w    $01a4,$088f
  99.     dc.w    $01a6,$000f
  100.     dc.w    $01aa,$0fff
  101.     dc.w    $01ac,$088f
  102.     dc.w    $01ae,$000f
  103.  
  104.     dc.w    $ffff,$fffe
  105.     
  106. gfxname:dc.b    'graphics.library',0
  107.     even
  108. gfxbase:dc.l    0
  109.  
  110. stor:    dc.l    0
  111. pln1:    dc.l    0
  112. pln2:    dc.l    0
  113. pln3:    dc.l    0
  114. pln4:    dc.l    0
  115. pln5:    dc.l    0
  116. sysint:    dc.w    0
  117. intsave:dc.l    0
  118. plnbase:dc.l    0
  119.  
  120. isr:    movem.l    d0-d7/a0-a6,-(sp)
  121.     move.w    #$0020,$dff09c
  122.     movem.l    (sp)+,d0-d7/a0-a6
  123.     rte
  124.  
  125. task:    move.w    $dff006,d0
  126.     and.w    #$ff00,d0
  127.     cmp.w    #$ff00,d0
  128.     bne    task
  129.     jsr    Star_move
  130.     rts
  131.  
  132.  
  133.     *****************************
  134.     *Note:-                   *
  135.     * A-Obj                   *
  136.     * B-Msk                     *
  137.     * C-Bck                     *
  138.     * D-Bck                     *
  139.     * M-00001111 10111000       *
  140.     *****************************
  141.  
  142.  
  143.  
  144. killspr:
  145.     move.l    #blnkspr,d0
  146.  
  147.     move.w    d0,sp0+6
  148.     move.w    d0,sp1+6
  149.     move.w    d0,sp2+6
  150.     move.w    d0,sp3+6
  151.     move.w    d0,sp4+6
  152.     move.w    d0,sp5+6
  153.     move.w    d0,sp6+6
  154.     move.w    d0,sp7+6
  155.     swap    d0
  156.     move.w    d0,sp0+2
  157.     move.w    d0,sp1+2
  158.     move.w    d0,sp2+2
  159.     move.w    d0,sp3+2
  160.     move.w    d0,sp4+2
  161.     move.w    d0,sp5+2
  162.     move.w    d0,sp6+2
  163.     move.w    d0,sp7+2
  164.     rts    
  165. blnkspr:ds.l    4
  166.  
  167.     ****************************************
  168.     *    Multi-purpose Stafield Creator    *
  169.     *                       *    
  170.     *        Written by Andy Clark         *    
  171.     *                       *    
  172.     *           3rd August 1990           *    
  173.     *                       *    
  174.     *      Strictly for use by anyone      *    
  175.     ****************************************
  176.  
  177.     ****************************************
  178.     *     Use the four equates for fx      *    
  179.     ****************************************
  180.     
  181. star_top    equ    $2c        ;first line
  182. star_height    equ    250        ;number of lines
  183. density        equ    2        ;density of stars (0-3)
  184. direction    equ    0        ;0-right 1-left
  185.  
  186.     ****************************************
  187.     *     Use the four equates for fx      *    
  188.     ****************************************
  189.  
  190. star0:    dc.w    %0000000000000110,%0000000000000111        ;slow
  191. star1:    dc.w    %0000000000011001,%0000000000011110        ;med
  192. star2:    dc.w    %0000000111000111,%0000000111111000        ;fast
  193.  
  194. den:    dc.b    3,7,15,31
  195.  
  196. numst0:    dc.w    0
  197. numst1:    dc.w    0
  198. numst2:    dc.w    0
  199.  
  200. stary:    dc.w    0    ;current y position
  201. stardat:dc.l    0    ;data for display
  202. starcnt:dc.l    0    ;number of lines used
  203. msb:    dc.w    0    ;gmt check
  204. dens:    dc.l    0    ;density store
  205.  
  206.     ** Call this once to set up stars
  207.     ** Attention: You must have sp0-2 defined on copper list    
  208.  
  209. Stars_on:
  210.     lea    den,a0
  211.     move.l    #density,d0
  212.     move.b    (a0,d0),dens+3
  213.  
  214.     lea    st0,a0
  215.     move.l    star0,d0
  216.     jsr    setstars
  217.     lea    st1,a0
  218.     move.l    star1,d0
  219.     jsr    setstars
  220.     lea    st2,a0
  221.     move.l    star2,d0
  222.     jsr    setstars
  223.  
  224.     move.l    #st0,d0
  225.     move.w    d0,sp0+6
  226.     swap    d0
  227.     move.w    d0,sp0+2
  228.  
  229.     move.l    #st1,d0
  230.     move.w    d0,sp1+6
  231.     swap    d0
  232.     move.w    d0,sp1+2
  233.  
  234.     move.l    #st2,d0
  235.     move.w    d0,sp2+6
  236.     swap    d0
  237.     move.w    d0,sp2+2
  238.  
  239.     rts
  240.  
  241.     ** Call this every frame
  242.  
  243. Setstars:
  244.     move.b    #0,msb
  245.     move.b    #star_top,stary
  246.     move.l    d0,stardat
  247.     move.l    #0,starcnt
  248.  
  249. .lp2:    jsr    random
  250.     and.l     dens,d1
  251.     add.b    d1,stary    ;updt stary position
  252.     bcc    .lp3        ;over gmt?
  253.     move.b    #1,msb
  254. .lp3:    add.l    d1,starcnt    ;inc count
  255.     move.l    #star_height,d0
  256.     cmp.l    starcnt,d0
  257.     blt    .lp        ;reached end
  258.     move.b    stary,(a0)    ;set ystart
  259.     bclr.b    #2,3(a0)
  260.     tst.b    msb        ;check over
  261.     beq    .lp5
  262.     bset.b    #2,3(a0)
  263. .lp5:    move.b    stary,2(a0)    
  264.     add.b    #1,2(a0)    ;set ystop
  265.     bcc    .lp4
  266.     move.b    #1,msb
  267. .lp4:    bclr.b    #1,3(a0)
  268.     tst.b    msb        ;check over
  269.     beq    .lp6
  270.     bset.b    #1,3(a0)
  271. .lp6:    jsr    random
  272.     move.b    d1,1(a0)    ;set xpos
  273.     add.b    #2,stary    ;updt for next y position
  274.     add.l    #4,a0        ;point to data
  275.     move.l    stardat,(a0)+    ;put data into display
  276.     add.l    #2,starcnt    ;in count
  277.     move.l    #star_height,d0
  278.     cmp.l    starcnt,d0
  279.     blt    .lp        ;reached end
  280.     bra    .lp2        ;get next star
  281. .lp:    move.l    #0,(a0)
  282.     rts
  283.  
  284. Star_move:
  285.     lea    st0,a0
  286.     move.l    #1,d0        ;speed
  287.     jsr    stmov
  288.     lea    st1,a0
  289.     move.l    #2,d0        ;speed
  290.     jsr    stmov
  291.     lea    st2,a0
  292.     move.l    #3,d0        ;speed
  293.     jsr    stmov
  294.     rts
  295. stmov:    move.l    #direction,d1
  296.     beq    .lp
  297.     neg.l    d0
  298. .lp    add.b    d0,1(a0)
  299.     add.l    #8,a0
  300.     tst.l    (a0)
  301.     bne    .lp
  302.     rts
  303.  
  304. random    moveq.l    #0,d1
  305.     lea    $fc0000,a6
  306.     move.l    framecount,d5
  307.     move.b    (a6,d5),d1
  308.     subq.l    #1,a6
  309.     and.l    #$07,d5
  310.     lea    rseed,a6
  311.     move.b    (a6,d5),d5
  312.     eor.b    d5,d1
  313.     add.l    #$01,framecount
  314.     cmp.l    #2000,framecount
  315.     blt    noz2
  316.     move.l    #0,framecount
  317. noz2    rts
  318. rseed    dc.b    $94,$2f,$47,$e2,$13,$c5,$76,$89
  319. framecount:
  320.     dc.l    0
  321.  
  322. st0:    ds.b    200*4
  323. st1:    ds.b    200*4
  324. st2:    ds.b    200*4
  325.  
  326.     ****************************************
  327.     *     Bottom of Starfield Routine      *    
  328.     ****************************************
  329.  
  330.